<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-11
 * Time: 22:43
 */

namespace frontend\widget;


use backend\models\Article;
use yii\base\Widget;
use yii\helpers\Html;

class CopyrightWidget extends Widget
{
    public $cate_id=8;

    public function run()
    {

        $cache = \Yii::$app->cache;
        $data = $cache->get('CopyrightWiget');
        if($data){
            $html = $data;
        }else{

                $html = ' <div class="footer w1210 bc mt10"><p class="links">';
                $links = $this->getData();
                foreach ($links as $link) {
                    $html .= '<a href="">' . $link["name"] . '</a> ｜';
                }
                $xin =Html::img('@web/images/xin.png');
                $kexin = Html::img('@web/images/kexin.jpg');
                $police =Html::img('@web/images/police.jpg');
                $beian = Html::img('@web/images/beian.gif');

                $html.=<<<AUTH
</p><p class="copyright">© 2005-2013 京东网上商城 版权所有，并保留所有权利。  ICP备案证书号:京ICP证070359号</p><p class="auth">
    
    <a href="">{$xin}</a>
    <a href="">{$kexin}</a>
    <a href="">{$police}</a>
    <a href="">{$beian}</a>
</p>
</div>
AUTH;

                $cache->set('CopyrightWiget',$html);
        }

        return $html;
    }

    public function getData(){
        return Article::find()->where(['article_category_id'=>$this->cate_id])->asArray()->all();
    }

}